import { useEffect, useState } from 'react';
import an58 from '@mmstudio/an000058';
import {
	Menu,
	MenuItem
} from '@szhsin/react-menu';
import { Result } from './api/account/userinfo.api';
import api from '../atoms/api';
import '@szhsin/react-menu/dist/index.css';



export default function Header() {
	//用户信息
	const [username, setUsername] = useState('');
	const [picture, setPicture] = useState('');

	useEffect(() => {
		void (async () => {
			const data = await an58<Result>(api['/api/account/userinfo'], 'get');
			setUsername(data.name);
			setPicture(data.picture);
			console.debug(data);
		})();
	}, []);
	return <>
		<div className='header'>
			<div className='v'>
				<img className='himg' src='/images/logosmall.png' />
				<span className='hlbl'>创新创业学院后台管理系统</span>
			</div>
			<div className='v'>
				<img className='img' src='/images/search.png' />
				<img className='img' src='/images/ask.png' />
				<img className='img1' src='/images/lingdang.png' />
				{picture && <img className='img2' src={picture} />}
				<span className='username'>{username}</span>
			</div>
			<style jsx>{`

.header{
display: flex;
height: 3rem;
width: 100vw;
flex-direction: row;
justify-content: space-between;
align-items: center;
background-color: #001529;
}
.v{
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.himg{
margin-left: 1rem;
margin-right: 0.5rem;
}
.hlbl{
	color: #FFFFFF;
	font-size: 1.125rem;
}
.img{
cursor: pointer;
height: 0.8125rem;
 width: 0.8125rem;
margin-right: 1.5rem;
}
.img1{
height: 0.9375rem;
 width: 0.75rem;
margin-right: 1.5rem;
cursor: pointer;
}
.img2{
height: 1.5rem;
 width: 1.5rem;
margin-right: 0.5rem;
cursor: pointer;
}
.username{
	color: #FFFFFF;
	font-size: 0.875rem;
margin-right: 3rem;
}

			`}</style>
		</div>
	</>;
}
